#include<iostream>
using namespace std;

const int N=1e6+10;
typedef long long ll;
ll arr[N];
ll n, m;
ll fun(ll x)
{
	ll ret=0;
	for(int i=1; i<=n; i++)
	{
		if(arr[i]>x) ret+=(arr[i]-x);
	}
	return ret;
}
int main()
{
	cin>>n>>m;
	for(int i=1; i<=n; i++) cin>>arr[i];
	ll left=0, right=3e9;
	while(left<right)
	{
		ll mid=(right+left+1)/2;
		if(fun(mid) >= m) left=mid;
		else right=mid-1;
	}
	cout<<left;
	return 0;
}
